package com.example.demo.config;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice
public class GlobaErrorHandler {
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public String handlerException(Exception e) {
		return "页面出现了异常"+e.getClass();
	}
	@ExceptionHandler(AccessDeniedException.class)
	@ResponseBody
	public String handlerAccessDeniedException(AccessDeniedException e) {
		return "<h1>你没有权限访问这个页面</h1>"+e.getClass();
		
	}
}
